package test.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBHelper {  
    public static final String url = "jdbc:mysql://119.23.100.56:3306/wave_apartment_landlord?useUnicode=true&characterEncoding=utf8&useSSL=false&tinyInt1isBit=true";  
    public static final String name = "com.mysql.cj.jdbc.Driver";  
    public static final String user = "wavedb_fh";  
    public static final String password = "apartment@wfsj$$";  
    
    static {
    	try {
			Class.forName(name);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
    
    public static Connection getConn() {
    	Connection conn = null;
    	try {  
    		conn = DriverManager.getConnection(url, user, password);//获取连接  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    	return conn;
    }
  
    public static void close(Connection conn) {  
    	try {
			conn.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }  
}  
